
# -*- coding: utf-8 -*-
import os
import re;

def batch_rename(path, prefix, replace_pair = {}, onlyshow = True):
    for file in os.listdir(path):
        aftfile = str(file)
        for key in replace_pair.keys():
            # aftfile = aftfile.replace(key,replace_pair[key])
            aftfile = re.sub(key, replace_pair[key], aftfile)
        aftfile = prefix + aftfile
        aftfile = aftfile.upper()
        if not onlyshow:
            try:
                os.rename(os.path.join(path,file),os.path.join(path,aftfile))
            except print("!"):
                print("Rename fail !!!!!!!! ", aftfile)
        print(file, " -> ", aftfile)

root_path = "Z:\日剧\非自然死亡" + "/"
prefix = ""

batch_rename(root_path, prefix + "" ,{
    ".第\d集.Unnatural.2018.": "",
    "BD-1080p.X264.AAC-99Mp4": ""
}, False)

# batch_rename(root_path + prefix + " ", prefix + " " ,{
#     "LYJ ": "",
# }, True)


# max_s = 12
# for i in range(1, max_s+1):
#     se_str = "SE" + str(i).zfill(2)
#     batch_rename(root_path + prefix + " " + se_str, prefix + " ", {
#         # "[Mm]arvel['s]{0,2}.[Ii]ron.[Ff]ist.": "",
#         # "The.Gifted.": "",
#         # "\(2017\) - " : "",
#         # " - " : ".",
#         # "- " : ".",
#         # "\.[a-zA-Z0-9#\u4e00-\u9fa5-&\.' +]*\.":".",
#         # "\.[\s\S]*\.":"."
#     }, False)